package com.dyna.core.exception;

import com.dyna.domain.resp.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author zhoucaiwang
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CustomException extends RuntimeException {

    /**
     * 业务错误码
     */
    private ResultCode resultCode;
    /**
     * 错误提示
     */
    private String message;

    public CustomException(String msg) {
        this.resultCode = ResultCode.FAILURE;
        this.message = msg;
    }

    public CustomException(ResultCode resultCode, String msg) {
        this.resultCode = resultCode;
        this.message = msg;
    }

    public ResultCode getCode() {
        return this.resultCode;
    }

    public CustomException setCode(ResultCode code) {
        this.resultCode = code;
        return this;
    }

    @Override
    public String getMessage() {
        return this.message;
    }

    public CustomException setMessage(String message) {
        this.message = message;
        return this;
    }

}
